package com.example.feignClients;

import com.example.config.FeignClientConfig;
import com.example.pojo.dto.UserInsertDTO;
import com.example.pojo.dto.UserPageQueryDTO;
import com.example.pojo.entity.User;
import com.example.pojo.entity.result.PageResult;
import com.example.pojo.entity.result.Result;
import com.example.pojo.vo.UserPageVO;
import com.example.pojo.vo.UserVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "userservice", path = "/admin/user", configuration = FeignClientConfig.class)
public interface UserClient {
    /**
     * 查询用户信息
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("查询用户信息")
    Result<UserVO> getUserById(@PathVariable Long id);

    /**
     * 用户列表分页查询
     *
     * @param userPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("用户列表分页查询")
    Result<PageResult<UserPageVO>> pageUser(@RequestParam("page") Integer page,
                                            @RequestParam("pageSize") Integer pageSize,
                                            @RequestParam(value = "surname", required = false) String surname,
                                            @RequestParam(value = "sex", required = false) String sex,
                                            @RequestParam(value = "phone", required = false) String phone,
                                            @RequestParam(value = "idNumber", required = false) String idNumber);

    /**
     * 新增用户
     *
     * @param userInsertDTO
     * @return
     */
    @PostMapping
    @ApiOperation("新增用户")
    Result<User> insertUser(@RequestBody UserInsertDTO userInsertDTO);
}
